<template>
  <div>
    <Form label-position="right" :label-width="400" :model="unemploymentItem">
      <Row class="mb20">
        <Col span="5" class="ivu-form-item-label">登记编号：</Col>
        <Col span="6" class="ivu-form-item-content">
          <Input v-model="unemploymentItem.acc0m1" placeholder="请输入登记编号"></Input>
        </Col>
        <Col span="5" class="ivu-form-item-label">失业日期：</Col>
        <Col span="6" class="ivu-form-item-content">
          <DatePicker v-model="unemploymentItem.adc210" type="date" format="yyyy-MM-dd" placeholder="请选择失业时间" style="width: 218px" @on-change="time"></DatePicker>
        </Col>
      </Row>
      <Row class="mb20">
        <Col span="5" class="ivu-form-item-label">失业登记原因：</Col>
        <Col span="6" class="ivu-form-item-content">
          <Select v-model="unemploymentItem.ajc093" style="width:218px">
            <Option v-for="item in reasonList" :value="item.value" :key="item.value">{{ item.label }}</Option>
          </Select>
        </Col>
        <Col span="5" class="ivu-form-item-label">此前享受失业保险待遇期限：</Col>
        <Col span="6" class="ivu-form-item-content">
          <Input v-model="unemploymentItem.acc021" placeholder="请输入整数月"></Input>
        </Col>
      </Row>
      <Row class="mb20">
        <Col span="5" class="ivu-form-item-label">首次失业登记时间：</Col>
        <Col span="6" class="ivu-form-item-content">
          <DatePicker v-model="unemploymentItem.acc022" type="date" format="yyyy-MM-dd" placeholder="请选择首次失业时间" style="width: 218px" @on-change="time"></DatePicker>
        </Col>
        <Col span="5" class="ivu-form-item-label">上次失业时间：</Col>
        <Col span="6" class="ivu-form-item-content">
          <DatePicker v-model="unemploymentItem.acc023" type="date" format="yyyy-MM-dd" placeholder="请选择上次失业时间" style="width: 218px" @on-change="time"></DatePicker>
        </Col>
      </Row>
      <Row class="mb20">
        <Col span="5" class="ivu-form-item-label">累计失业次数：</Col>
        <Col span="6" class="ivu-form-item-content">
          <Input v-model="unemploymentItem.acc024" placeholder="请输入整数" />
        </Col>
        <Col span="5" class="ivu-form-item-label">就业意愿：</Col>
        <Col span="6" class="ivu-form-item-content">
          <Select v-model="unemploymentItem.acc025" style="width:218px">
            <Option v-for="item in yyList" :value="item.value" :key="item.value">{{ item.label }}</Option>
          </Select>
        </Col>
<!--        <Col span="5" class="ivu-form-item-label">失业前单位编号：</Col>-->
<!--        <Col span="6" class="ivu-form-item-content">-->
<!--          <Input v-model="unemploymentItem.aab001" placeholder="请输入失业前单位编号"></Input>-->
<!--        </Col>-->
      </Row>
<!--      <Row class="mb20">-->
<!--        <Col span="5" class="ivu-form-item-label">失业前所在单位经济类型：</Col>-->
<!--        <Col span="6" class="ivu-form-item-content">-->
<!--          <Select v-model="unemploymentItem.aab020" style="width:218px">-->
<!--            <Option v-for="item in emTylpList" :value="item.value" :key="item.value">{{ item.label }}</Option>-->
<!--          </Select>-->
<!--        </Col>-->
<!--        <Col span="5" class="ivu-form-item-label">失业前单位所属行业：</Col>-->
<!--        <Col span="6" class="ivu-form-item-content">-->
<!--          <Select v-model="unemploymentItem.aab022" style="width:218px">-->
<!--            <Option v-for="item in industryList" :value="item.value" :key="item.value">{{ item.label }}</Option>-->
<!--          </Select>-->
<!--        </Col>-->
<!--      </Row>-->
<!--      <Row class="mb20">-->
<!--        <Col span="5" class="ivu-form-item-label">失业前单位所属产业：</Col>-->
<!--        <Col span="6" class="ivu-form-item-content">-->
<!--          <Select v-model="unemploymentItem.aab054" style="width:218px">-->
<!--            <Option v-for="item in cyList" :value="item.value" :key="item.value">{{ item.label }}</Option>-->
<!--          </Select>-->
<!--        </Col>-->
<!--        <Col span="5" class="ivu-form-item-label">就业意愿：</Col>-->
<!--        <Col span="6" class="ivu-form-item-content">-->
<!--          <Select v-model="unemploymentItem.acc025" style="width:218px">-->
<!--            <Option v-for="item in yyList" :value="item.value" :key="item.value">{{ item.label }}</Option>-->
<!--          </Select>-->
<!--        </Col>-->
<!--      </Row>-->
      <Row class="mb20">
        <Col span="5" class="ivu-form-item-label">是否有培训意愿：</Col>
        <Col span="6" class="ivu-form-item-content">
          <Select v-model="unemploymentItem.acc026" style="width:218px">
            <Option v-for="item in pxList" :value="item.value" :key="item.value">{{ item.label }}</Option>
          </Select>
        </Col>
        <Col span="5" class="ivu-form-item-label">培训专业：</Col>
        <Col span="6" class="ivu-form-item-content">
          <Select v-model="unemploymentItem.acc027" style="width:218px">
            <Option v-for="item in pxzyList" :value="item.aca111" :key="item.aca111">{{ item.aca112 }}</Option>
          </Select>
        </Col>
      </Row>
      <Row class="mb20">
        <Col span="5" class="ivu-form-item-label">备注：</Col>
        <Col span="6" class="ivu-form-item-content">
          <Input v-model="unemploymentItem.aae013" type="textarea" :autosize="{maxRows: 7,minRows: 1}" placeholder="请输入备注" />
        </Col>
        <Col span="5" class="ivu-form-item-label">经办日期：</Col>
        <Col span="6" class="ivu-form-item-content">
          <Input v-model="unemploymentItem.aae036" v-if="unemploymentItem.aae036 === ''" placeholder="请点击获取当前时间" @on-focus="saveTime"></Input>
          <Input v-model="unemploymentItem.aae036" v-else readonly placeholder="请点击获取当前时间" @on-focus="saveTime"></Input>
        </Col>
      </Row>
    </Form>
  </div>
</template>

<script>
import itemdata from '../itemdata'
import { date2str } from '@/api/eventlist'
import { createPost } from '@/api/post'
export default {
  name: 'index.vue',
  data () {
    return {
      aa: '',
      reasonList: itemdata.unemploymentReasonList,
      emTylpList: itemdata.economicsTypelist,
      industryList: itemdata.industryList,
      cyList: itemdata.industryCategoryList,
      yyList: itemdata.employmentDesireList,
      // 培训意愿 ACC026
      pxList: [
        { value: '0', label: '无' },
        { value: '1', label: '有' }
      ],
      pxzyList: [],
      unemploymentItem: {
        apiName: 'sq4sydj',
        acc0m1: '',
        adc210: '',
        ajc093: '',
        acc021: '',
        acc022: '',
        acc023: '',
        acc024: '',
        // aab001: '',
        // aab020: '',
        // aab022: '',
        // aab054: '',
        acc025: '',
        acc026: '',
        acc027: '',
        aae013: '',
        aae011: '',
        aae017: '',
        aae019: '',
        aae020: '',
        aae022: '',
        aae036: '',
        adc200: '1'
      }
    }
  },
  props: {
    unemploymentItem1: Object,
    personinfo: Object
  },
  methods: {
    saveTime () {
      let data = new Date()
      let HH = data.getHours()
      let mm = data.getMinutes()
      let ss = data.getSeconds()
      this.unemploymentItem.aae036 = date2str(data) + ' ' + HH + ':' + mm + ':' + ss
    },
    test () {
      let reg = /^[0-9]+$/
      // if (this.unemploymentItem.ajc093 === '20' || this.unemploymentItem.ajc093 === '30' || this.unemploymentItem.ajc093 === '80') {
      //   if (this.unemploymentItem.aab020 === '') {
      //     this.$Notice.error({ title: '请选择失业前所在单位经济类型', desc: '' })
      //     return false
      //   } else if (this.unemploymentItem.aab022 === '') {
      //     this.$Notice.error({ title: '请选择所属行业', desc: '' })
      //     return false
      //   } else if (this.unemploymentItem.aab054 === '') {
      //     this.$Notice.error({ title: '请选择所属产业', desc: '' })
      //     return false
      //   }
      // }
      if (this.unemploymentItem.acc026 === '1') {
        if (this.unemploymentItem.acc027 === '') {
          this.$Notice.error({ title: '请选择培训专业', desc: '' })
          return false
        }
      }
      if (this.unemploymentItem.acc0m1 === '' || this.unemploymentItem.acc0m1 === undefined) {
        this.$Notice.error({ title: '请输入登记编号', desc: '' })
        return false
      } else if (date2str(this.unemploymentItem.adc210) === '' || date2str(this.unemploymentItem.adc210) === undefined) {
        this.$Notice.error({ title: '请选择失业时间', desc: '' })
        return false
      } else if (date2str(this.unemploymentItem.acc022) === '' || date2str(this.unemploymentItem.acc022) === undefined) {
        this.$Notice.error({ title: '请选择首次失业时间', desc: '' })
        return false
      } else if (date2str(this.unemploymentItem.aae036) === '' || date2str(this.unemploymentItem.aae036) === undefined) {
        this.$Notice.error({ title: '请选择经办日期', desc: '' })
        return false
      } else if (this.unemploymentItem.ajc093 === '' || this.unemploymentItem.ajc093 === undefined) {
        this.$Notice.error({ title: '请输入失业登记原因', desc: '' })
        return false
      } else if (reg.test(this.unemploymentItem.acc021) === false) {
        this.$Notice.error({ title: '请输入正确此前享受失业保险待遇期限', desc: '' })
        return false
      } else if (reg.test(this.unemploymentItem.acc024) === false) {
        this.$Notice.error({ title: '请输入正确累计失业次数', desc: '' })
        return false
      } else if (this.unemploymentItem.acc025 === '' || this.unemploymentItem.acc025 === undefined) {
        this.$Notice.error({ title: '请选择就业意愿', desc: '' })
        return false
      } else if (this.unemploymentItem.acc026 === '' || this.unemploymentItem.acc026 === undefined) {
        this.$Notice.error({ title: '请选择是否有培训意愿', desc: '' })
        return false
      } else {
        this.$emit('unemploymentItem', this.unemploymentItem)
      }
    },
    // 培训专业
    findPxzyList () {
      let data = {
        apiName: 'sq4gjzyfl'
      }
      createPost(data).then(ret => {
        this.pxzyList = ret.data.data.data
        /* if (ret.data.result === '1') {

        } else if (ret.data.result === '0') {
          this.$Notice.error({ title: ret.data.errmsg, desc: '' })
        } */
      })
    },
    time () {
      this.unemploymentItem.acc022 = date2str(this.unemploymentItem.acc022)
      this.unemploymentItem.acc023 = date2str(this.unemploymentItem.acc023)
      this.unemploymentItem.adc210 = date2str(this.unemploymentItem.adc210)
    }
  },
  mounted () {
    this.findPxzyList()
  },
  watch: {
    unemploymentItem1 (a) {
      this.unemploymentItem = a
    }
  }
}
</script>

<style scoped>

</style>

<!--else if (this.unemploymentItem.aae011 === '' || this.unemploymentItem.aae011 === undefined) {
this.$Notice.error({ title: '请输入经办人代码', desc: '' })
return false
} else if (this.unemploymentItem.aae017 === '' || this.unemploymentItem.aae017 === undefined) {
this.$Notice.error({ title: '请输入经办机构代码', desc: '' })
return false
} else if (this.unemploymentItem.aae019 === '' || this.unemploymentItem.aae019 === undefined) {
this.$Notice.error({ title: '请输入经办人', desc: '' })
return false
} else if (this.unemploymentItem.aae020 === '' || this.unemploymentItem.aae020 === undefined) {
this.$Notice.error({ title: '请输入经办机构名称', desc: '' })
return false
} else if (this.unemploymentItem.aae022 === '' || this.unemploymentItem.aae022 === undefined) {
this.$Notice.error({ title: '请输入经办机构行政区划', desc: '' })
return false
}-->
